<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui/css/H-ui.min.css" />
        <%--引起冲突的样式--%>
    <%--<link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/table.css"/>--%>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/assets/H-ui/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/bootstrap.css"/>
    <!--_footer 作为公共模版分离出去-->
        <script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
        <script src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
        <!--/_footer /作为公共模版分离出去-->
    <title>报告列表管理 -  </title>
</head>
<body>

<section class="Hui-article-box">
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="cl pd-5 bg-1 bk-gray mt-20">
                 <div class="mt-20">
                     <h3 align="center">体检报告列表</h3>
                <table class="table table-border table-bordered table-hover table-bg table-sort">
                    <thead>
                    <input type="text" value="1" name="num" id="num" hidden>
                    <tr class="text-c">
                        <th width="100">体检者</th>
                        <th width="90">体检项</th>
                        <th width="30">科室</th>
                        <th width="30">费用</th>
                        <th width="30">状态</th>
                        <th width="100">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:if test="${not empty page}">
                        <c:forEach items="${page.list}" var="reportItem">
                    <tr class="text-c">
                        <td>${sessionScope.user.userName}</td>
                        <td>${reportItem.item.itemName}</td>
                        <td>${reportItem.desk.deskName}</td>
                        <td>${reportItem.item.itemMoney}</td>
                        <td>${reportItem.state.stateName}</td>
                            <c:if test="${reportItem.stateId==16}">
                                <td class="td-manage">
                                    <a onclick="balance(${reportItem.reportItemId})" class="btn-primary btn-sm">开始体检</a>
                                </td>
                            </c:if>
                            <c:if test="${reportItem.stateId==17}">
                                <td class="td-manage">
                                    <a href="${pageContext.request.contextPath}/report/upItemState.action?num=1&reportItemId=${reportItem.reportItemId}"
                                       class="btn-primary btn-sm">开始体检</a>
                                </td>
                            </c:if>
                        </c:forEach>
                    </c:if>
                    </tbody>
                </table>
                     <div id="page" style="float: right" align="center">
                         总共${page.pages}页，当前第${page.pageNum}页,每页总共${page.pageSize}。
                         <a id="firstPage" class="btn-sm btn-primary" onclick="changeNum(${page.prePage})">上一页</a>
                         <a id="lastPage" class="btn-sm btn-primary" onclick="changeNum(${page.nextPage})">下一页</a>
                     </div>
                 </div>
            </div>
        </article>
    </div>
</section>
<script type="text/javascript">
    $(function () {
        if(${page.isLastPage}){
            $("#lastPage").removeAttr("onclick");
        }
    });
    function changeNum(obj) {
        var num=obj;
        window.location.href="${pageContext.request.contextPath}/report/reportList.action?num="+num;
    }

    function balance(obj){var num=$("#num").val();
     var reportItemId=obj;
        $.post("${pageContext.request.contextPath}/report/reportBalance.action",
            {"reportItemId":reportItemId},
            function(date){
                if(date==true){
                    location.href="${pageContext.request.contextPath}/report/upItemState.action?num="+num+"&reportItemId="+reportItemId;
                }else if(date==false){
                    alert("提醒用户余额不足");
                }
            })
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>